using Godot;
using kemocard.Scripts.Common;
using kemocard.Scripts.Module.Run;
using kemocard.Scripts.MVC;

namespace kemocard.Components.List;

public partial class ButtonItem : Button
{
    public string Id;
    private string _description;

    public string Description
    {
        get => _description;
        set
        {
            _description = value;
            Text = value;
        }
    }

    public object Data;

    public override void _Ready()
    {
        base._Ready();
        Pressed += OnPressed;
    }

    private void OnPressed()
    {
        var model = GameCore.ControllerMgr.GetControllerModel<RunModel>(ControllerType.Run);
        model?.OnStoryAction(Id);
    }

    public override void _ExitTree()
    {
        Pressed -= OnPressed;
        base._ExitTree();
    }
}